diff options
| author | Adam Soltys <[email protected]> | 2025-02-07 22:23:00 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-07 22:23:00 -0800 |
| commit | 479cb9ad44d05b56cd2e60735687702fc37487a0 (patch) | |
| tree | fad9e4080887c2f11e8f750714c83e619f833afa /src/routes/(app)/apps/[pubkey]/+page.server.ts | |
| parent | d92352dafc6d9e62716625d75be2316039a97a69 (diff) | |
| download | coinos-ui-479cb9ad44d05b56cd2e60735687702fc37487a0.tar.gz coinos-ui-479cb9ad44d05b56cd2e60735687702fc37487a0.zip | |
nwc connections
Diffstat (limited to 'src/routes/(app)/apps/[pubkey]/+page.server.ts')
| -rw-r--r-- | src/routes/(app)/apps/[pubkey]/+page.server.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/routes/(app)/apps/[pubkey]/+page.server.ts b/src/routes/(app)/apps/[pubkey]/+page.server.ts new file mode 100644 index 00000000..a2cc50e7 --- /dev/null +++ b/src/routes/(app)/apps/[pubkey]/+page.server.ts @@ -0,0 +1,26 @@ +import getRates from "$lib/rates"; +import { auth, fd, get, post } from "$lib/utils"; +import { fail, redirect } from "@sveltejs/kit"; + +export const load = async ({ cookies, params, parent }) => { + const { pubkey } = params; + const { user } = await parent(); + const rates = await getRates(); + const rate = rates[user.currency]; + const app = await get(`/app/${pubkey}`, auth(cookies)); + return { app, rate }; +}; + +export const actions = { + default: async ({ cookies, request }) => { + try { + const body = await fd(request); + await post("/app", body, auth(cookies)); + } catch (e) { + const { message: error } = e as Error; + return fail(400, { error }); + } + + redirect(307, "/settings/nostr"); + }, +}; |
